package com.systop.utils;

/**
 * @author jsj
 * @date 2022/5/3
 *
 * 错误码和错误信息定义类
 * 1. 错误码定义规则为 5 为数字
 * 2. 前两位表示业务场景，最后三位表示错误码。例如：100001。10:通用 001:系统未知
 异常
 * 3. 维护错误码后需要维护错误描述，将他们定义为枚举形式
 * 错误码列表：
 * 10: 通用
 * 001：参数格式校验
 *
 *
 */
public enum BizCodeEnum {
    UNKNOWN_EXCEPTION(10000,"系统未知异常！"),
    VALID_EXCEPTION(10001,"参数格式校验失败！"),

    SUCCESS(200, "访问成功"),
    ADD_SUCCESS(201,"新增成功"),
    DEL_SUCCESS(202,"删除成功"),
    UDP_SUCCESS(203,"更新成功"),

    INVALID_QUERY(205,"无效的查询"),

    FAIL(300, "fail"),
    BODY_NOT_MATCH(400, "请求的数据格式不符！"),
    SIGNATURE_NOT_MATCH(401, "请求的数字签名不匹配！"),
    NOT_LOGIN(402, "登陆错误！"),
    NOT_FOUND(404, "未找到该资源！"),
    GATEWAY_TIMEOUT(405, "网关连接超时"),
    PARAMETER_ERROR(409, "参数错误！"),
    INTERNAL_SERVER_ERROR(500, "服务器内部错误！"),
    SERVER_BUSY(503, "服务器正忙，请稍后再试！"),
    UNDEFINED_ERROR(1000, "未知错误！"),
    NOTE(1001, "自定义提示！"),

    EXPIRE(1002, "Session过期了"),

    /*用户部分*/
    USER_NOT_ADMIN(10100,"用户权限不足"),
    //登录
    USERNAME_OR_PASSWORD_ERROR(10110,"用户名或密码错误"),
    PASSWORD_VALID_ERROR(10111,"密码验证失败"),
    VERIFICATION_CODE_ERROR(10112,"验证码不正确"),
    IS_ONLINE(10113, "用户在线！"),
    NOT_ONLINE(10114, "用户不在线！"),
    ILLEGAL_EMAIL_EXCEPTION(10115,"邮箱不合法"),
    ILLEGAL_PHONE_EXCEPTION(10116,"手机号不合法"),
    SMS_CODE_SENDED(10117,"已发送验证码"),
    SMS_CODE_EXCEPTION(10118,"短信验证码获取频率太高,请稍后再试"),
    PHONE_CAPTCHA_EXCEPTION(10119,"短信验证码错误"),
    //新增
    // ADD_USER_SUCCESS(10120,"删除成功!"),
    USER_EXIST(10120,"添加失败,用户已存在"),
    //修改
    INVALID_ADD_USER(10130,"无效的用户添加"),
    //删除
    HAS_CONSIGNEE(10140,"删除失败,存在对应收货人"),
    DEL_FAIL(10141,"删除失败,用户不存在"),

    //订单部分
    TOKEN_VERIFY(10150,"订单信息过期，请刷新再次提交"),
    AMOUNT_COMPARISON_FAILED(10152,"订单商品价格发生变化，请确认后再次提交"),
    STOCK_LOCK_FAIL(10152,"库存锁定失败，商品库存不足")
    ;

    private int code;
    private String msg;

    BizCodeEnum(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public int getCode() {
        return code;
    }
    public String getMsg() {
        return msg;
    }
}
